using Godot;
using Godot.Collections;
using System;
using System.Data.Common;
using System.Dynamic;
using System.Runtime;

public partial class TileMapComp : Godot.TileMap
{
	// Called when the node enters the scene tree for the first time.





	private int range = 0;






	public override void _Ready()
	{
		//EventManager.getInstance().addListener(EventType.EVENT_TILE_MAP_SHOW_CAN_WAKL_RANGE, OnShowMoveRange);
		//EventManager.getInstance().addListener(EventType.EVENT_TILE_MAP_INIT, OnEventInit);

	}

	public void initMap()
	{
		/*TileMapUtil.ClearLayer(this, TileMapLayerName.BEGINPOS);
		TileMapUtil.ClearLayer(this, TileMapLayerName.CANWALK);
		TileMapUtil.ClearLayer(this, TileMapLayerName.PATH);
		TileMapUtil.ClearLayer(this, TileMapLayerName.ATTACKRANGE);

		TileMapUtil.EnableLayer(this, TileMapLayerName.BACKGROUND, true);
		TileMapUtil.EnableLayer(this, TileMapLayerName.BEGINPOS, false);
		TileMapUtil.EnableLayer(this, TileMapLayerName.CANWALK, false);
		TileMapUtil.EnableLayer(this, TileMapLayerName.PATH, false);
		TileMapUtil.EnableLayer(this, TileMapLayerName.ATTACKRANGE, false);*/
	}


	public void initData()
	{
		/*tileData.Clear();
		pathTileData.Clear();
		initPos = new Vector2I(0, 0);
		range = 0;*/

	}

	public void Init()
	{
		initMap();
		initData();
	}

	private void OnShowMoveRange(object sender, EventParams param)
	{
		/*if (!TileMapUtil.CheckLayerIsShow(this, TileMapLayerName.CANWALK))
		{
			tileData = TileMapUtil.ShowActorCanMoveTileRangeByStep(this, (Vector2I)param.paramDict["beginPos"], (int)param.paramDict["moveRange"]);
			initPos = (Vector2I)param.paramDict["beginPos"];
			range = (int)param.paramDict["moveRange"];
		}
		else
		{

		}*/


	}



	/*private void OnClickMap()
	{
		Vector2 pos = GetViewport().GetMousePosition();
		Vector2I endPos = TileMapUtil.ChangePosToTile(pos.X, pos.Y);
		if (tileData.ContainsPos(endPos))
		{
			_ = TileMapUtil.FindWayInCanWalkLayer(this, initPos, endPos, tileData);
		}
		else
		{
			GD.Print("点的不是地方");
		}
	}*/

	public override void _Input(InputEvent @event)
	{
		base._Input(@event);

		/*if (@event.IsPressed())
		{
			Vector2 pos = GetViewport().GetMousePosition();
			Vector2I endPos = TileMapUtil.ChangePosToTile(pos.X, pos.Y);
			if (pathTileData.Contains(endPos) && TileMapUtil.CheckLayerIsShow(this, TileMapLayerName.CANWALK))
			{

				EventParams param = new EventParams();
				param.paramDict.Add("PathData", pathTileData);
				EventManager.getInstance().dispatchEvent(EventType.EVENT_TILE_MAP_ACTOR_MOVE, param);

			}
			else
			{
				if (tileData.ContainsPos(endPos) && TileMapUtil.CheckLayerIsShow(this, TileMapLayerName.CANWALK))  //行走界面打开且点击有数据
				{
					pathTileData = TileMapUtil.FindWayInCanWalkLayer(this, initPos, endPos, tileData);
				}
				else
				{
					GD.Print("点的不是地方");
				}
			}




		}*/


	}

}




